﻿using Dou.UI;
using UnityEngine;

namespace Simple
{
    public class Test_TabGroup : MonoBehaviour
    {
        public DToggleGroup group;

        void Awake()
        {
            group.onChanging += GroupOnChanging;
            group.onChanged.AddListener(GroupOnChanged);
        }

        private bool GroupOnChanging(int index)
        {
            if (index == 2) // 第 3 项不允许点击
            {
                Debug.Log("装备未到开放等级！");
                return false;
            }
            return true;
        }

        private void GroupOnChanged(int index)
        {
            Debug.Log("标签页切换：" + index);
            Debug.Log("当前选中标签索引：" + group.selectedIndex);
        }

        public void SelectNext()
        {
            var index = group.selectedIndex;
            index++;
            index %= group.toggleCount;
            group.selectedIndex = index;
        }

        public void SelectNon()
        {
            group.selectedIndex = -1;
        }
    }
}
